package com.meida.module.pay.provider.service.impl;

import com.meida.common.mybatis.base.service.impl.BaseServiceImpl;
import com.meida.common.mybatis.entity.EntityMap;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.common.mybatis.query.CriteriaSave;
import com.meida.common.security.OpenHelper;
import com.meida.module.pay.client.entity.InvoiceReceiver;
import com.meida.module.pay.provider.mapper.PayInvoiceReceiverMapper;
import com.meida.module.pay.provider.service.PayInvoiceReceiverService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 发票主体 实现类
 *
 * @author flyme
 * @date 2019-07-20
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PayInvoiceReceiverServiceImpl extends BaseServiceImpl<PayInvoiceReceiverMapper, InvoiceReceiver> implements PayInvoiceReceiverService {

    @Override
    public ResultBody beforeListEntityMap(CriteriaQuery<InvoiceReceiver> cq, InvoiceReceiver ordInvoiceReceiver, EntityMap requestMap) {
        Long userId = OpenHelper.getUserId();
        cq.eq(InvoiceReceiver.class, "userId", userId);
        return ResultBody.ok();
    }

    @Override
    public ResultBody beforeAdd(CriteriaSave cs, InvoiceReceiver ordInvoiceReceiver, EntityMap extra) {
        Long userId = OpenHelper.getUserId();
        ordInvoiceReceiver.setUserId(userId);
        return ResultBody.ok();
    }
}
